from flask import Flask
from .routes.image_api import image_bp
from .routes.user_api import user_bp
from .routes.question_api import question_bp
from .routes.record_api import record_bp
from .routes.auth import auth_bp
from .routes.knowledge import knowledge_bp
from .routes.leaderboard import leaderboard_bp
from .routes.points_api import points_bp
from .routes.llm_api import llm_bp
from app.extensions import db
from config import Config


def register_blueprints(app):
    app.register_blueprint(image_bp)
    app.register_blueprint(user_bp)
    app.register_blueprint(question_bp)
    app.register_blueprint(record_bp)
    app.register_blueprint(auth_bp)
    app.register_blueprint(knowledge_bp)
    app.register_blueprint(leaderboard_bp)
    app.register_blueprint(points_bp)
    app.register_blueprint(llm_bp)


def create_app():
    app = Flask(__name__)

    app.config.from_object(Config)    # 或者 app.config.from_pyfile('../config.py')

    db.init_app(app)

    register_blueprints(app)

    return app
